package LoginServer;

import java.io.FileNotFoundException;
import javax.swing.JOptionPane;

/**
 * Application Entry Class
 */
public class Main
{
    private static String m_SettingPath = "C:\\LoginServerSettings.xml";
    private static Settings m_Settings;
    /**
     * Houdt de huidige settings bij
     * @return
     */
    public static Settings getSettings()
    {
        return m_Settings;
    }


    /**
     * Main wordt gebruikt om de LoginServer op te starten.
     * @param args the command line arguments
     */
    public static void main(String args[])
    {
        
        // Load Settings
        try
        {
            m_Settings = Settings.Load(m_SettingPath);
        }
        catch (FileNotFoundException ex)
        {
            m_Settings = Settings.getDefault();
            try
            {
                m_Settings.Save(m_SettingPath);
                JOptionPane.showMessageDialog(null, "<html>Settings have been created on '" + m_SettingPath + "'.<br />Please check if they are valid and run the program again.</html>", "Warning: Settings Not Found", 1);
            }
            catch (FileNotFoundException ex2)
            {
                JOptionPane.showMessageDialog(null, "Settings have not been found and can't also be created on '" + m_SettingPath + "'.", "Error: Settings Not Found", 1);
            }
        }

        java.awt.EventQueue.invokeLater(new Runnable()
        {
            public void run()
            {
                new LoginServerManager().setVisible(true);
            }
        });
    }

}
